//
//  UIView+Extra.m
//  JFBase
//
//  Created by Jianbo Cai on 2019/11/28.
//  Copyright © 2019 Alan Wang. All rights reserved.
//

#import "UIView+Extra.h"

@implementation UIView (Extra)

- (void)setMaskCornerRadius:(CGFloat)radius {
    [self setCornerRadius:radius corners:UIRectCornerAllCorners viewSize:self.bounds.size];
}

- (void)setCornerRadius:(CGFloat)radius corners:(UIRectCorner)corners viewSize:(CGSize)viewSize {
    UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, viewSize.width, viewSize.height) byRoundingCorners:corners cornerRadii:CGSizeMake(radius,radius)];
    CAShapeLayer *maskLayer = [[CAShapeLayer alloc]init];
    maskLayer.frame = self.bounds;
    maskLayer.path = maskPath.CGPath;
    self.layer.mask = maskLayer;
}

@end
